package com.mcgrady.structure;

import org.junit.Test;

/**
 * @author McGrady
 */
public class LoopTest {
    @Test
    public void whileStructure() {
        int i = 1;
        while (i <= 10) {
            System.out.println(i);
            i++;
        }
    }

    @Test
    public void doWhileStructure() {
        int i = 100;
        do {
            System.out.println(i);
            i++;
        } while (i <= 10);
    }

    @Test
    public void forStructure() {
        for (int i = 1; i <= 10; i++) {
            System.out.println(i);
        }
    }

    @Test
    public void continueWord(){
        for (int i = 0; i < 10 ; i++) {
            if(i == 6){
                continue;
            }
            System.out.println("循环到了" + i);
        }
    }

    @Test
    public void breakWord(){
        String result = "没有";
        for (int i = 100; i < 201; i++) {
            if(i % 23 == 0){
                result = "有";
                System.out.println(i);
                break;
            }
        }
        System.out.println(result);
    }
}
